<?php

class admin_template_user_manager_listing extends admin_theme
{

	protected function head()
	{
	?>
<script type="text/javascript" language="javascript" src="apps/user/templates/manager/js/listing.js"></script>
	<?php
	}

	protected function center()
	{

	    $users = $this->get('users');
	    
		$ui_listing = bone::get_admin_ui('listing');
		$ui_listing->can('create');
		$ui_listing->can('edit');
		$ui_listing->can('unblock');
		$ui_listing->can('block');
		$ui_listing->can('delete');

		$ui_listing->set_filter(
            array(
            	'type'=>'text', 
            	'name'=>'key', 
            	'label'=>'关健字', 
            	'value'=>$this->get('key'), 
            	'width'=>'120px'
            ), 
            array(
            	'type'=>'select', 
                'name'=>'status', 
            	'label'=>'状态', 
            	'options'=>array(
                    '-1'=>'所有',
            		'0'=>'公开',
                    '1'=>'屏蔽'
                ),
                'value'=>$this->get('status')
            )
		);

		foreach($users as $user)
		{
			$user->register_time =	date('Y-m-d H:i',$user->register_time);
			$user->last_visit_time = date('Y-m-d H:i',$user->last_visit_time);
		}
		$ui_listing->set_data($users);
		$ui_listing->set_fields(
			array(
    			'name'=>'id',
    			'label'=>'ID',
    			'align'=>'center',
				'width'=>'30',
			    'order_by'=>'id'
			),
    		array(
    			'name'=>'avatar',
    			'label'=>'头像',
    			'align'=>'center',
    			'width'=>'50',
    		    'template'=>'<img src="../{avatar_s}" />'
    		),
    		array(
    			'name'=>'username',
    			'label'=>'用户名',
    			'align'=>'left',
    		    'order_by'=>'username'
    		),
    		array(
    			'name'=>'name',
    			'label'=>'名称',
    			'align'=>'left',
    		    'width'=>'80'
    		),
    		array(
    			'name'=>'email',
    			'label'=>'邮箱',
    			'align'=>'center',
    		    'width'=>'200',
    		    'order_by'=>'email'
    		),
    		array(
    			'name'=>'register_time',
    			'label'=>'注册时间',
    			'align'=>'center',
    		    'width'=>'120',
    		    'order_by'=>'register_time'
    		),
    		array(
    			'name'=>'last_visit_time',
    			'label'=>'最近登陆',
    			'align'=>'center',
    		    'width'=>'120',
    		    'order_by'=>'last_visit_time'
    		),
    		array(
    			'name'=>'is_admin',
    			'label'=>'后台权限',
    			'align'=>'center',
    		    'width'=>'80',
    		    'template'=>'<a href="javascript:;" onclick="javascript:setAdmin({id})" class="icon status-{is_admin}" id="status-{id}"></a>',
    		    'order_by'=>'is_admin'
			)
		);
		
		
		$ui_listing->set_pagination( $this->get('pagination') );
		$ui_listing->order_by($this->get('order_by'), $this->get('order_by_dir'));
		$ui_listing->display();


	}	

}
?>